package cz.muni.fi.pa165.library.api;

import java.util.Date;
import java.util.List;

/**
 *
 * @author Filip Ligac
 */
public interface BorrowService {

    /**
     * Creates a new borrow and stores it into database.
     *
     * @param borrowTO borrow entity to be created
     * @return created borrow
     * @throws IllegalArgumentException if borrow is null or borrow's attributes
     * are not correct or sufficient
     */
    public BorrowTO createBorrow(BorrowTO borrowTO) throws IllegalArgumentException;

    /**
     * Returns a list of all borrows in the database.
     *
     * @return list of all borrows in the database.
     */
    public List<BorrowTO> findAllBorrows();

    /**
     * Returns borrow for a given borrowID.
     *
     * @param borrowID ID of a borrow
     * @return borrow of a given borrowID
     * @throws IllegalArgumentException if id is null or not positive
     */
    public BorrowTO findBorrowByID(Long borrowID) throws IllegalArgumentException;
    public List<BorrowTO> findBorrowsByReader(ReaderTO user);
    /**
     * Updates expiration date for a borrow.
     *
     * @param borrowTO Borrow to be updated
     * @param newExpirationDate new expiration date for a borrow
     * @return borrow with updated expiration date
     * @throws IllegalArgumentException if parameter(s) are incorrect
     */
    public void updateExpirationDate(BorrowTO borrowTO, Date newExpirationDate) throws IllegalArgumentException;

    /**
     * Returns a few books from a borrow.
     *
     * @param borrowTO borrow
     * @param titlesTO list of all books to be returned
     * @return borrow with returned books
     * @throws IllegalArgumentException if parameter(s) are incorrect
     */
    public BorrowTO returnBooks(BorrowTO borrowTO, List<BookTO> titlesTO) throws IllegalArgumentException;

    /**
     * Adds books to an existing borrow.
     *
     * @param borrowTO borrow
     * @param titlesTO list of all books to be returned
     * @return borrow with added books
     * @throws IllegalArgumentException if parameter(s) are incorrect
     */
    public void borrowBooks(BorrowTO borrowTO, List<BookTO> titlesTO) throws IllegalArgumentException;

    /**
     * Deletes borrow from database.
     *
     * @param borrowTO borrow to be deleted
     * @return true if successfull, false otherwise
     * @throws IllegalArgumentException if parameter is null
     */
    public boolean deleteBorrow(BorrowTO borrowTO) throws IllegalArgumentException;
}
